/*
 * @Author: Li Zengkun
 * @Date: 2022-08-11 16:26:50
 * @LastEditors: Li Zengkun
 * @LastEditTime: 2022-08-13 11:15:12
 * @Description: axios-config
 */
// 1. 引入
// import axios from './axios.min.js'
axios.defaults.baseURL = 'http://localhost:3002'

// 请求拦截器
axios.interceptors.request.use((config) => {
    console.log('经过了请求拦截器');
    let token = localStorage.getItem('token')
    console.log(token);
    if (token) {
        config.headers.Authorization = `Bearer ${token}`
    }
    return config
}, (error) => {
    return Promise.reject(error)
})

// 响应拦截器
axios.interceptors.response.use((response) => {
    return response.data;
}, (error) => {
    return Promise.reject(error)
})